home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Circular Layout ƒ / QDGX shell misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-20  |  3.7 KB  |  177 lines  |  [TEXT/KAHL]

  1. /**\
  2. |**| =====================================================================
  3. |**|
  4. |**|    QDGX shell misc.c
  5. |**|
  6. |**|    This file contains utility and menu handling routines for
  7. |**|    the QuickDraw GX shell program.
  8. |**|
  9. |**|    ©1992-1994  Apple Computer, Inc.
  10. |**|    All rights reserved.
  11. |**|
  12. |**| =====================================================================
  13. \**/
  14.  
  15.  
  16. #include "QDGX shell.h"
  17.  
  18.  
  19. /**\
  20. |**| ---------------------------------------------------------------------
  21. |**| DoMenuCommand()
  22. |**| This routine handles the dispatching of our menu requests.
  23. |**| ---------------------------------------------------------------------
  24. \**/
  25. void DoMenuCommand (long menuResult)
  26. {
  27.     short                menuID;
  28.     short                menuItem;
  29.     Str255                daName;
  30.     OSErr                err;
  31.     gxDialogResult        result;
  32.     
  33.     menuID = menuResult >>16;
  34.     menuItem = menuResult & 0x0000ffff;
  35.     
  36.     switch (menuID)
  37.     {
  38.         case mApple:
  39.             switch (menuItem)
  40.             {
  41.                 case iAbout:                /* display About box */
  42.                     NoteAlert(rAboutBoxID,nil);
  43.                     break;
  44.                 
  45.                 default:                    /* handle DA selection */
  46.                     GetItem(GetMHandle(mApple), menuItem, daName);
  47.                     OpenDeskAcc(daName);
  48.                     break;
  49.             }
  50.             break;
  51.  
  52.  
  53.         case mFile:
  54.             switch (menuItem)
  55.             {                        
  56.                 case iNew:                    /* create new window */
  57.                     err = DoCreateNew();
  58.                     break;
  59.                                             
  60.                 case iOpen:                    /* open saved window */
  61.                     break;
  62.                                             
  63.                 case iClose:                /* close front window */
  64.                     DoDispose(FrontWindow());
  65.                     break;
  66.                                             
  67.                 case iSave:                    /* save front window */
  68.                     break;
  69.                                             
  70.                 case iPageSetup:            /* perform page setup */
  71.                     HiliteMenu(0);
  72.                     err = DoFormat(FrontWindow(), &result);
  73.                     break;
  74.                                             
  75.                 case iPrintOne:                /* perform print-one */
  76.                     err = DoPrintOne(FrontWindow());
  77.                     break;
  78.                     
  79.                 case iPrint:                /* perform print */
  80.                     HiliteMenu(0);
  81.                     err = DoPrinting(FrontWindow());
  82.                     break;
  83.  
  84.                 case iQuit:
  85.                     gQuitting = true;
  86.                     break;
  87.             }
  88.             break;
  89.  
  90.  
  91.         case mEdit:
  92.             break;
  93.     }
  94.     HiliteMenu(0);
  95. }
  96.  
  97.  
  98. /**\
  99. |**| ---------------------------------------------------------------------
  100. |**| GetDocOvalShape()
  101. |**| This utility routine returns the oval shape
  102. |**| attached to a window's document.
  103. |**| ---------------------------------------------------------------------
  104. \**/
  105. gxShape GetDocOvalShape (WindowPtr wind)
  106. {
  107.     TH_Doc    doc;
  108.     gxShape    docOval = nil;
  109.  
  110.     if (wind)
  111.     {
  112.         doc = (TH_Doc) GetWRefCon(wind);
  113.         docOval = (*doc)->docOval;
  114.     }
  115.     
  116.     return docOval;
  117. }
  118.  
  119. /**\
  120. |**| ---------------------------------------------------------------------
  121. |**| GetDocEraseShape()
  122. |**| This utility routine returns the eraser shape
  123. |**| attached to a window's document.
  124. |**| ---------------------------------------------------------------------
  125. \**/
  126. gxShape GetDocEraseShape (WindowPtr wind)
  127. {
  128.     TH_Doc    doc;
  129.     gxShape    eraseOval = nil;
  130.  
  131.     if (wind)
  132.     {
  133.         doc = (TH_Doc) GetWRefCon(wind);
  134.         eraseOval = (*doc)->eraseOval;
  135.     }
  136.     
  137.     return eraseOval;
  138. }
  139.  
  140.  
  141. /**\
  142. |**| ---------------------------------------------------------------------
  143. |**| GetDocJob()
  144. |**| This utility routine returns the print job attached to a window's document.
  145. |**| ---------------------------------------------------------------------
  146. \**/
  147. gxJob GetDocJob (WindowPtr wind)
  148. {
  149.     TH_Doc    doc;
  150.     gxJob        docJob = nil;
  151.  
  152.     if ( wind != NULL )
  153.     {
  154.         doc = (TH_Doc) GetWRefCon(wind);
  155.         docJob = (*doc)->docJob;
  156.     }
  157.     
  158.     return docJob;
  159. }
  160.  
  161.  
  162. /**\
  163. |**| ---------------------------------------------------------------------
  164. |**| MyStrLength()
  165. |**| This function takes the length of a C-style string quickly without
  166. |**| requiring an ANSI library to be linked in.
  167. |**| ---------------------------------------------------------------------
  168. \**/
  169. short MyStrLength (char *s)
  170. {
  171.     short len;
  172.  
  173.     for (len = 0; *s++ != 0; len++) ;
  174.     return len;
  175. }
  176.  
  177.